import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
// import { rules} from '/@/utils/helper/validator';
// import { render } from '/@/utils/common/renderUtils';
import { orgList } from './TSubmission.api';
//列表数据
export const columns: BasicColumn[] = [
  // {
  //  title: '租户号',
  //  align:"center",
  //  dataIndex: 'tenantId'
  // },
  {
    title: '送检编号',
    align: "center",
    dataIndex: 'submissionNo',
    helpMessage: '年月日+租户编号+2位自增。例子：2023-1-01-01'
  },
  {
    title: '检测类型',
    align: "center",
    dataIndex: 'type',
    customRender: (data) => {
      return data.record.type == 1 ? '品质' : '土壤';
    }
  },
  {
    title: '样品名称',
    align: "center",
    dataIndex: 'bizName'
  },
  {
    title: '样品量',
    align: "center",
    dataIndex: 'sampleSize',
    customRender: (data) => {
      return data.record.sampleSize ? data.record.sampleSize + 'kg' : '';
    }
  },
  // {
  //  title: '相关检测编号',
  //  align:"center",
  //  dataIndex: 'inspectionId'
  // },
  {
    title: '送检单位',
    align: "center",
    dataIndex: 'tenantId_dictText'
  },
  {
    title: '送检人',
    align: "center",
    dataIndex: 'submitter'
  },
  {
    title: '联系方式',
    align: "center",
    dataIndex: 'submitterContact'
  },
  // {
  //  title: '样品描述',
  //  align:"center",
  //  dataIndex: 'sampleDescription'
  // },
  {
    title: '送检日期',
    align: "center",
    dataIndex: 'submitDate'
  },
  // {
  //  title: '预计报告日期',
  //  align:"center",
  //  dataIndex: 'expectedReportDate',
  //  customRender: (data) => {
  //    // 创建一个指定日期的Date对象
  //    var date = new Date(data.record.submitDate);
  //    // 将日期加一天
  //    date.setDate(date.getDate() + 1);
  //    // 获取加一天后的日期
  //    var nextDay = date.toISOString().split('T')[0];
  //    return nextDay;
  //  }
  // },
  {
    title: '送检状态',
    align: "center",
    dataIndex: 'statusDictText',
    auth: 'traceability:biz:submission:list'
  },
  // {
  //  title: '备注',
  //  align:"center",
  //  dataIndex: 'remarks'
  // },
  // {
  //  title: '业务表id',
  //  align:"center",
  //  dataIndex: 'bizId'
  // },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "送检人",
    field: 'submitter',
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   label: '租户号',
  //   field: 'tenantId',
  //   component: 'Input',
  //   show: false
  // },
  {
    label: '检测类型',
    field: 'type',
    defaultValue: 1,
    component: 'RadioGroup',
    componentProps: {
      options: [
        {
          label: '品质',
          value: 1,
        },
        {
          label: '土壤',
          value: 2,
        },
      ],
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请选择检测类型!' },
      ];
    }
  },
  {
    label: '样品名称',
    field: 'bizId',
    component: 'JSearchSelect',
    componentProps: {
      dict: 't_product,name,no',
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请选择样品!' },
      ];
    },
  },
  {
    label: '样品量',
    field: 'sampleSize',
    component: 'InputNumber',
    componentProps: {
      addonAfter: 'KG'
    }
  },
  {
    label: '送检编号',
    field: 'submissionNo',
    component: 'Input',
    show: false
  },
  {
    label: '相关检测编号',
    field: 'inspectionId',
    component: 'Input',
    show: false
  },
  {
    label: '主要检测指标及要求',
    field: 'sampleDescription',
    component: 'InputTextArea',
    componentProps: {
      style: 'height: 150px'
    }
  },
  {
    label: '送检日期',
    field: 'submitDate',
    component: 'DatePicker',
    componentProps: {
      style: {
        width: '50%'
      },
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
  },
  {
    label: '送检人',
    field: 'submitter',
    component: 'Input',
  },
  {
    label: '联系方式',
    field: 'submitterContact',
    component: 'Input',
  },
  {
    label: '预计报告日期',
    field: 'expectedReportDate',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss'
    },
    show: false
  },
  {
    label: '送检状态',
    field: 'status',
    component: 'Input',
    show: false
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'JInputPop',
    show: false
  },
  {
    // todo 需要使用租户用户
    label: '检测机构',
    field: 'testOrgId',
    component: 'ApiSelect',
    componentProps: {
      params: { pageSize: 10000 },
      api: orgList,
      resultField: 'records',
      labelField: 'name',
      valueField: 'id',
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请选择检测机构!' },
      ];
    }
  },
  {
    label: '',
    field: 'addOrg',
    component: 'Input',
    slot: 'addOrg'
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
